<?php
$tb=array("drug","user","history","drug_history","hospital");
function C($a){
	include "db2.php";
	return $db[$a];
}
$my_con=mysql_connect(C('DB_HOST').":".C('DB_PORT'),C('DB_USER'),C('DB_PWD'));
if(!$my_con){
		die('无法连接'.mysql_error());
	}
mysql_select_db(C('DB_NAME'),$my_con);
//取得表字段名
$query="SELECT * from ".C('DB_PREFIX').$tb[1];
$result=mysql_query($query,$my_con);
mysql_query("SET NAMES 'UTF8'");
$arr="";
for($i=1;$i<mysql_num_fields($result);$i++){
	$ziduan=mysql_field_name($result,$i);
	$arr[$i]=$ziduan;
}
$zichuan=implode(",",$arr);
echo $zichuan."<br/>";

$id="420512198501011009";
$ph=13800138000;
$num=0;
require "n.php";
foreach($name as $i) {
	$id=bcadd($id,1);
	echo $id."<br/>";
	$ph=$ph+1;
	$ph=strval($ph);
	//随机产生1~3个字的名，暂不考虑少数民族
	$b="";//名初始化
	$rand=rand(1,2);
	for($n=1;$n<=$rand;$n++){
	$b=$b.getRandomName();
	}

	
	$j="'".$i."大人'";
	$i="'".$i.$b."'";//连接姓名
	$exec="insert into ".C('DB_PREFIX').$tb[1]."(".$zichuan.") values (".$i.",".$id.",".$j.",".$ph.");";
	//echo $exec."<br/>";
	mysql_query($exec,$my_con);
	if($erro=mysql_error()) echo $num." 次错误！！".$erro."<br/>";
	else echo $num . '次成功<br/>';
	$num=$num+1;
	
}
mysql_close($my_con);

?>